<template>
	<view style="padding: 20rpx;">
		<view class="form-box">
			<u-form labelPosition="top" label-width="85">
				<u-form-item label="收件人: ">
					<u-input v-model="form.contactName" placeholder="请输入收件人姓名"></u-input>
				</u-form-item>
				<u-form-item label="手机号: ">
					<u-input type="number" v-model="form.contactMobile" placeholder="请输入收件人手机号"></u-input>
				</u-form-item>
				<u-form-item label="详细地址: ">
					<u-textarea v-model="form.fullAddr" placeholder="请输入详细的收货地址"></u-textarea>
				</u-form-item>
			</u-form>
		</view>
		
		<view>
			<u-button type="success" text="提交" @click="submitForm"></u-button>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				form: {
					id: undefined,
					contactName: undefined,
					contactMobile: undefined,
					fullAddr: undefined
				}
			}
		},
		created() {
			this.getAddressInfo();
		},
		methods: {
			getAddressInfo() {
				this.$request("/appRecoverApi/owner/queryRecycleRecAddrList", 'get').then(res => {
					if(res.data && res.data.length > 0) {
						this.form = res.data[0]
					}
					console.log("获取到的数据", res.data)
					console.log(this.form)
				})
			},
			submitForm() {
				this.$request("/appRecoverApi/owner/createOrUpdateRecycleRecAddr", "post", this.form).then(res => {
					this.getAddressInfo();
					uni.showToast({
						title:"操作成功",
						icon: "success"
					})
				})
			},
		}
	}
</script>

<style scoped lang="scss">
	.form-box {
		background-color: #fff;
		padding: 20rpx;
		border-radius: 20rpx;
	}
</style>
